import { getDashboardData } from '../api/dashboard'
const getDefaultState = () => {
  return {
    listData: {},
    backlog: {},
    orderLineChart: {},
    organOverview: {},
    todayData: {},
    transportTaskList: {}
  }
}

const state = getDefaultState()

const getters = {

  listData(state) {
    return state.listData
  }

}
const mutations = {
  saveData(state, val) {
    state.listData = val
    const { backlog,
      orderLineChart,
      organOverview,
      todayData,
      transportTaskList } = val
    state.backlog = backlog
    state.orderLineChart = orderLineChart
    state.organOverview = organOverview
    state.todayData = todayData
    state.transportTaskList = transportTaskList
  }
}

const actions = {
  async getData(context) {
    const res = await getDashboardData()
    context.commit('saveData', res.data)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getters
}

